﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="ihongma.Web.UI.Page.article_list" ValidateRequest="false" %>
<%@ Import namespace="System.Collections.Generic" %>
<%@ Import namespace="System.Text" %>
<%@ Import namespace="System.Data" %>
<%@ Import namespace="ihongma.Common" %>

<script runat="server">
override protected void OnInit(EventArgs e)
{

	/* 
		This page was created by ihongma Template Engine at 2014/3/11 19:02:05.
		本页面代码由ihongma模板引擎生成于 2014/3/11 19:02:05. 
	*/

	base.OnInit(e);
	StringBuilder templateBuilder = new StringBuilder(220000);
	templateBuilder.Append("<!doctype html>\r\n<html >\r\n<head>\r\n	\r\n	<title>jQuery UI Datepicker - Display inline</title>\r\n	\r\n   \r\n    <link href=\"../../css/jquery.ui.theme.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n    <link href=\"../../css/jquery.ui.core.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n     <link href=\"../../css/jquery.ui.datepicker.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n    <script src=\"../../scripts/jquery/jquery-1.10.2.min.js\" type=\"text/javascript\"></");
	templateBuilder.Append("script>\r\n    <script src=\"../../scripts/jquery/jquery.ui.datepicker.js\" type=\"text/javascript\"></");
	templateBuilder.Append("script>\r\n    <script src=\"../../scripts/jquery/jquery.ui.datepicker-zh-TW.js\" type=\"text/javascript\"></");
	templateBuilder.Append("script>\r\n    <script src=\"../../scripts/json2.js\" type=\"text/javascript\"></");
	templateBuilder.Append("script>\r\n		<script type=\"text/javascript\">\r\n		    var starti = 3;\r\n		    var currDT;\r\n		    var aryDay = new Array(\"日\", \"一\", \"二\", \"三\", \"四\", \"五\", \"六\"); //显示星期  \r\n		    var lastDay; //页面显示的最后一天\r\n		    var firstDay; //页面显示的第一天\r\n		    //初始化日期加载\r\n		    function initDate(myDates) {\r\n		        currDT = myDates;\r\n		        tempDate = myDates;\r\n		        minDatetime = new Date();\r\n		        minDatetime.setDate(minDatetime.getDate() + 2);\r\n		       \r\n		        setcontent(\"a\");\r\n		        \r\n		        //重新赋值\r\n		        lastDay = getDays()[13]; //本周的最后一天\r\n		        firstDay = getDays()[0]; //本周的第一天\r\n\r\n		    }\r\n		    //取得当前日期两周内的某天\r\n		    function getWeek(i) {\r\n		        var now = tempDate;\r\n		        var n = now.getDay();\r\n		        var start = new Date(tempDate);\r\n		        n = n == 0 ? 7 : n;\r\n		        start.setDate(now.getDate() - n + i); //取得一周内的第一天、第二天、第三天...\r\n		        return start;\r\n		    }\r\n\r\n		    //取得当前日期两周内的14天\r\n		    function getDays() {\r\n		        var days = new Array();\r\n		        for (var i = 0; i <= 14; i++) {\r\n		            days[i - 1] = getWeek(i);\r\n		        }\r\n		        return days;\r\n		    }\r\n\r\n		    //取得下两周的日期数(共14天)\r\n		    function getNextWeekDatas(ndt) {\r\n		        var days = new Array();\r\n		        for (var i = 1; i <= 14; i++) {\r\n		            var dt = new Date(ndt);\r\n		            days[i - 1] = getNextWeek(dt, i);\r\n		        }\r\n		        return days;\r\n		    }\r\n		 \r\n		    //指定日期的下两周(后14天)\r\n		    function getNextWeek(dt, i) {\r\n		        var today = dt;\r\n		        today.setDate(today.getDate() + i);\r\n		        return today;\r\n		    }\r\n\r\n\r\n		    //取得上两周的日期数(共14天)\r\n		    function getPreviousWeekDatas(ndt) {\r\n		        var days = new Array();\r\n		        for (var i = -14; i <= -1; i++) {\r\n		            var dt = new Date(ndt);\r\n		            days[14 + i] = getPreviousWeek(dt, i);\r\n		        }\r\n		        return days;\r\n		    }\r\n\r\n		    //指定日期的上两周(前14天)\r\n		    function getPreviousWeek(dt, i) {\r\n		        var today = dt;\r\n		        today.setDate(today.getDate() + i);\r\n		        return today;\r\n		    }\r\n\r\n		    //下两周\r\n		    function nextWeek() {\r\n		        currDT.setDate(currDT.getDate() + 14); //重设时间\r\n		        setcontent(\"b\");\r\n		        firstDay = getNextWeekDatas(lastDay)[0]; //注意赋值顺序1\r\n		        lastDay = getNextWeekDatas(lastDay)[13]; //注意赋值顺序2\r\n		    }\r\n		\r\n		     Data = [];\r\n           \r\n		    var type = ");
	templateBuilder.Append(category_id.ToString());

	templateBuilder.Append("; //类别\r\n            ");
	DataTable goods_list = get_article_list("goods", category_id, page, "status=0", out totalcount, out pagelist, "goods_list", category_id, "__id__");

	templateBuilder.Append("\r\nvar plist=[");
	int dr__loop__id=0;
	foreach(DataRow dr in goods_list.Rows)
	{
		dr__loop__id++;


	templateBuilder.Append("{ \"id\": " + Utils.ObjectToStr(dr["id"]) + ",\"q\": 1,\"j\":" + Utils.ObjectToStr(dr["sell_price"]) + "}");
	if (dr__loop__id!=goods_list.Rows.Count)
	{

	templateBuilder.Append(",");
	}	//end for if

	}	//end for if

	templateBuilder.Append("];\r\n          \r\n		    function setcontent(Days) {\r\n		        if (Days == \"a\") {\r\n\r\n		            var d = new Date(currDT);\r\n\r\n		            Data.length = 0;\r\n		            for (var j = 0; j < starti; j++) {\r\n\r\n		                s = j == 0 ? 0 : 1;\r\n		                Data.push({ \"id\": j, g: [], \"e\": d.setDate(d.getDate() + s), \"t\": type });\r\n                       \r\n		                for (var h = 0; h < plist.length; h++) {\r\n		                    Data[j].g.push(plist[h]);\r\n		                }\r\n		            }\r\n\r\n		        }\r\n                \r\n \r\n		        showdate.innerHTML = currDT.toLocaleDateString(); //显示日期  \r\n		        //在表格中显示一周的日期  \r\n		        var objTB = document.getElementById(\"mytable\"); //取得表格对象\r\n		        var dw = currDT.getDay(); //从Date对象返回一周中的某一天(0~6)\r\n		        var tdDT; //日期\r\n		        var $tr = $('<tr>');\r\n		        $('#mytable').empty();\r\n		        \r\n		        for (var i = 0; i < 14; i++) {\r\n		            if (Days == \"a\") {\r\n		                tdDT = getDays()[i];\r\n\r\n		            } else if (Days == \"b\") {\r\n		                tdDT = getNextWeekDatas(lastDay)[i];\r\n		            }\r\n		            else {\r\n		                tdDT = getPreviousWeekDatas(firstDay)[i];\r\n		            }\r\n		            if (i ==0) {\r\n		                if (minDatetime - tdDT > 0 || minDatetime.Format(\"yyyy-MM-dd\") == tdDT.Format(\"yyyy-MM-dd\")) {\r\n		                    $(\"#previousweek\").hide();\r\n		                }\r\n		                else {\r\n		                    $(\"#previousweek\").show();\r\n		                }\r\n		            }\r\n		            dw = tdDT.getDay(); //星期几\r\n\r\n		            if (minDatetime - tdDT < 0 || minDatetime.Format(\"yyyy-MM-dd\")==tdDT.Format(\"yyyy-MM-dd\")) {\r\n\r\n\r\n		                var itemst= jQuery.grep(\r\n                Data, function (item, index) { return new Date(parseInt(item.e, 10)).Format(\"yyyy-MM-dd\") == tdDT.Format(\"yyyy-MM-dd\"); });\r\n		                \r\n		                if (itemst.length>0) {\r\n		                    var $td = $('<td>').html(tdDT.getMonth() + 1 + \"月\" + tdDT.getDate() + \"日 星期\" + aryDay[dw] + \"6瓶id:\" + itemst[0].id);\r\n		                }\r\n		                else {\r\n		                    var $td = $('<td>').html(tdDT.getMonth() + 1 + \"月\" + tdDT.getDate() + \"日 星期\" + aryDay[dw]);\r\n		                }\r\n\r\n		                //   \r\n\r\n		                $tr.append($td);\r\n\r\n\r\n		                //objTB.rows[0].cells[i].style.color = \"red\";//currDT突出显示  \r\n		            }\r\n		            else {\r\n		                var $td = $('<td>').html(tdDT.getMonth() + 1 + \"月\" + tdDT.getDate() + \"日 星期\" + aryDay[dw] + \"亲，你错过了~\");\r\n		                $tr.append($td);\r\n\r\n\r\n\r\n		            }\r\n		        }\r\n		        $(\"#mytable\").append($tr);\r\n\r\n		    }\r\n		    Date.prototype.Format = function (fmt) { //author: meizz \r\n		        var o = {\r\n		            \"M+\": this.getMonth() + 1, //月份 \r\n		            \"d+\": this.getDate(), //日 \r\n		            \"h+\": this.getHours(), //小时 \r\n		            \"m+\": this.getMinutes(), //分 \r\n		            \"s+\": this.getSeconds(), //秒 \r\n		            \"q+\": Math.floor((this.getMonth() + 3) / 3), //季度 \r\n		            \"S\": this.getMilliseconds() //毫秒 \r\n		        };\r\n		        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + \"\").substr(4 - RegExp.$1.length));\r\n		        for (var k in o)\r\n		            if (new RegExp(\"(\" + k + \")\").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : ((\"00\" + o[k]).substr((\"\" + o[k]).length)));\r\n		        return fmt;\r\n		    }\r\n		    \r\n		    //上一周\r\n		    function previousWeek() {\r\n		        currDT.setDate(currDT.getDate() - 14);\r\n		        setcontent(\"c\");\r\n		        //重新赋值\r\n		        lastDay = getPreviousWeekDatas(firstDay)[13]; //注意赋值顺序1\r\n		        firstDay = getPreviousWeekDatas(firstDay)[0]; //注意赋值顺序2\r\n		    }\r\n</");
	templateBuilder.Append("script>\r\n<script type=\"text/javascript\" src=\"");
	templateBuilder.Append("/templates/test");
	templateBuilder.Append("/js/cart1.js\"></");
	templateBuilder.Append("script>\r\n       \r\n	<script  type=\"text/javascript\">\r\n	    $(function () {\r\n	        var myDate = new Date();\r\n	        myDate.setDate(myDate.getDate() + 2);\r\n	        $(\"#datepicker\").datepicker({ \"minDate\": myDate,\r\n	            showOtherMonths: true,\r\n	            selectOtherMonths: true,\r\n	            onSelect: function (selectedDate) {\r\n	                initDate(new Date(selectedDate));\r\n	            }\r\n	        });\r\n\r\n	        initDate(myDate);\r\n	    });\r\n	    function test(v) {\r\n	        starti = v;\r\n	        initDate(currDT);\r\n	    }\r\n	</");
	templateBuilder.Append("script>\r\n</head>\r\n<body  >\r\ntype:<div ><a href=\"javascript:void(0);\" onclick=\"test(1)\">1天</a><br /><a href=\"javascript:void(0);\" onclick=\"test(3)\">3天</a><br /><a href=\"javascript:void(0);\" onclick=\"test(5)\">5天</a><br /><a href=\"javascript:void(0);\"\" onclick=\"test(7)\">7天</a></div>\r\nDate: <div id=\"datepicker\"></div>\r\n\r\n\r\n<table align=\"center\"  >\r\n	<tr>  \r\n		<td>\r\n			<input type=\"button\" id=\"previousweek\" name=\"previousweek\" value=\"上一周\" onClick=\"previousWeek();\"/>\r\n			<span id=\"showdate\"></span>\r\n			<input type=\"button\" name=\"previousweek\" value=\"下一周\" onClick=\"nextWeek();\"/>\r\n		</td>\r\n	</tr>  \r\n</table>\r\n<!--显示日期-->\r\n<table id=\"mytable\" cellspacing=\"0\" border=\"1\" align=\"center\" width=\"90%\">\r\n	\r\n</table>\r\n      <a href=\"javascript:void(0);\" class=\"buy\" onclick=\"CartAdd(this, '");
	templateBuilder.Append(Utils.ObjectToStr(config.webpath));
	templateBuilder.Append("', 2, '");
	templateBuilder.Append(linkurl("shopping","confirm"));

	templateBuilder.Append("');\">立即购买</a>\r\n          \r\n</body>\r\n</html>\r\n");
	Response.Write(templateBuilder.ToString());
}
</script>
